# 构建阶段
FROM node:20-alpine AS builder
WORKDIR /app

# 安装git
RUN apk add --no-cache git

# 从Gitee拉取代码（master分支）
RUN git clone -b master https://f0541b04bb9c1e0709b7ef5bed2807cc@gitee.com/wang_dongsheng/what-to-eat.git .

# 安装pnpm
RUN npm install -g pnpm

# 安装依赖
RUN pnpm install

# 执行构建命令
RUN pnpm run build:h5

# 生产阶段
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
    